package lab01;

import java.util.Random;
import java.util.Scanner;

/**
 * Created by AIR on 2017/10/17.
 */
import java.util.Random;//导入随机数类
import java.util.Scanner;//导入输入者类
public class Test8 {
    public static void main(String[] args) {

        int rightNum = new Random().nextInt(100) + 1;

        Scanner scanner = new Scanner(System.in);

        int input ;

        System.out.println("猜数字游戏开始了！");
        do{
            System.out.print("请输入数字(1-100)：");
            input = scanner.nextInt();

            if(input > rightNum){
                System.out.println("猜大了!请重新输入：");
            }
            else if(input < rightNum){
                System.out.println("猜小了!请重新输入：");
            }
        }while(input != rightNum);

        System.out.println("猜对了" + rightNum);

    }
}

